﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Rtgs.master" AutoEventWireup="true" CodeFile="pembayaran_stprecorddetailolist.aspx.cs" Inherits="page_rtgs_pembayaran_stprecorddetailolist" %>

<asp:Content ID="ctnBody" ContentPlaceHolderID="body" runat="server">
    <link type="text/css" rel="stylesheet" href="<%= ResolveClientUrl("~/css/ui.jqgrid.css") %>" />
    <script type="text/javascript" src="<%= ResolveClientUrl("~/script/i18n/grid.locale-en.js") %>"></script>
    <script type="text/javascript" src="<%= ResolveClientUrl("~/script/jquery.jqGrid.min.js") %>"></script>
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
    <br />
    <div>
        <a href="javascript:void(0);" id="panelFind" class="dialog_link ui-state-default ui-corner-all"
            title="Find"><span class="ui-icon ui-icon-search"></span>Open Find Form</a>
    </div>
    <br />
    <div id="divFindData">
   <div id="div1">
        <fieldset style="width: 950px;">
            <legend>Find</legend>
            <table border="0">
                <tr>
                    <td>
                        Value Date
                    </td>
                    <td style="padding-left: 20px">
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:DropDownList ID="ddlValueDate" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                                <td style="padding-left: 35px">
                                    Batch Ref
                                </td>
                                <td style="padding-left: 20px">
                                     <asp:DropDownList ID="ddlBatchRef" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                                <td style="padding-left: 20px">
                                    Ref. No
                                </td>
                                <td style="padding-left: 20px">
                                    <asp:DropDownList ID="ddlRefNo" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                                <td style="padding-left: 20px">
                                    To
                                </td>
                                <td style="padding-left: 20px">
                                      <asp:DropDownList ID="ddlToMember" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        TRN
                    </td>
                    <td style="padding-left: 20px">
                        <table border="0">
                            <tr>
                                <td>
                                    <asp:DropDownList ID="ddlTrn" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                                
                                <td style="padding-left: 35px">
                                    Status
                                </td>
                                <td style="padding-left:35px">
                                     <asp:DropDownList ID="ddlStatus" runat="server" Width="150px"></asp:DropDownList>
                                </td>
                                <td style="padding-left: 20px">
                                    TC
                                </td>
                                <td style="padding-left: 45px">
                                    <asp:TextBox ID="txtTC" runat="server"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <a href="javascript:void(0);" id="Find" class="dialog_link ui-state-default ui-corner-all"
                            title="Find"><span class="ui-icon ui-icon-search"></span>Find</a>&nbsp; <a href="javascript:void(0);"
                                id="Reset" class="dialog_link ui-state-default ui-corner-all" title="Reset"><span
                                    class="ui-icon ui-icon-close"></span>Reset</a>
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    </div>
    <br />
    <div>
        	<a href="#" id="dialog_link" class="dialog_link ui-state-default ui-corner-all" alt="Add" onclick="OpenForm('add')"><span class="ui-icon ui-icon-plus"></span>Add</a>
    </div>
    <br />
    <table id="table" class="scroll" cellpadding="0" cellspacing="0">
    </table>
    <div id="pager" class="scroll">
    </div>
    <br />
    <div id="dialog" title="Default dialog">
    </div>
    <script type="text/javascript">

        var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o.ashx") %>';

        $('#table').jqGrid({
            url: handlerUrl + '?method=getdata&typeOutgoing=pembayaran',
            datatype: 'json',
            colNames: ['recordDetailOtrRelatedtrn', 'Value Date', 'Status', 'RSN', 'To Member', 'TRN', 'REL TRN', 'Amount', 'Batch Ref'],
            colModel: [
                { name: 'recordDetailOtrRelatedtrn', hidden: true, index: 'RECORD_DETAIL_OTR_RelatedTRN', width: 60 },
           		{ name: 'recordDetailOtrValuedate', index: 'RECORD_DETAIL_OTR_ValueDate', width: 150 },
           		{ name: 'recordDetailOrecordStatus', index: 'RECORD_DETAIL_ORECORD_Status', width: 150 },
                { name: 'recordDetailOrecordRsncde', index: 'RECORD_DETAIL_ORECORD_Rsncde', width: 150 },
                { name: 'recordDetailOtrTomember', index: 'RECORD_DETAIL_OTR_ToMember', width: 150 },
                { name: 'recordDetailOtrTrn', index: 'RECORD_DETAIL_OTR_TRN', width: 150 },
                { name: 'recordDetailOtrRelatedtrn', index: 'RECORD_DETAIL_OTR_RelatedTRN', width: 150 },
                { name: 'recordDetailOtrAmount', index: 'RECORD_DETAIL_OTR_Amount', width: 150 },
                { name: 'recordDetailOrecordOhBatchreference', index: 'RECORD_DETAIL_ORECORD_OH_BatchReference', width: 150 }
           	],
            rowNum: 10,
            id: 'RECORD_DETAIL_OTR_RelatedTRN',
            multiselect: true,
            rowList: [5, 10, 15, 20],
            pager: '#pager',
            sortname: 'RECORD_DETAIL_OTR_RelatedTRN',
            sortorder: "asc",
            viewrecords: true,
            jsonReader: { repeatitems: false },
            width: 'auto',
            height: '100%',
            caption: 'Outgoing Drop',
            ajaxGridOptions: { cache: false },
            ondblClickRow: function () {
                //OpenForm('edit');
            }
        });

        function OpenForm(ctl) {

            var grid = $("#table");
            var selIds = grid.jqGrid('getGridParam', 'selarrrow'),
                selText = [];
            $.each(selIds, function () {
                selText.push(grid.jqGrid('getCell', this, 'recordDetailOtrRelatedtrn'));
            });

            if (ctl == "edit") {

                if (selIds.length == 0) {
                }
                else if (selIds.length > 1) {
                    alert('Pilih satu record untuk ubah data.');
                }
                else {

                    var url = ".../form/rtgs/StpRecordDetailO_Form.aspx" + "?typeOutgoing=all&Id=" + encodeURIComponent(selText);
                    alert(url);
                    $("#dialog").load(url).dialog({ autoOpen: false, modal: true, height: 600, width: 1100, title: 'Display Data' });
                    $("#dialog").dialog('open');
                }

            }
            else if (ctl == "add") {
                $("#dialog").load('../../form/rtgs/StpRecordDetailO_Form.aspx?typeOutgoing=pembayaran').dialog({ autoOpen: false, modal: true, height: 600, width: 1100, title: 'Add Data' });
                $("#dialog").dialog('open');
            }
            else {
                var result = window.confirm('Are you sure that you want to delete?');
                if (result) {
                    CallAjax("../ajaxhandler/rtgs/stp_config.ashx", "?method=delete" + "&id=" + selText);

                    setTimeout("$('#table').trigger('reloadGrid');", 3000);
                }
            }
        }

        $(document).ready(function () {
            $("#" + "divFindData").toggle();

            $('#panelFind').click(function () {
                $("#" + "divFindData").toggle();
            });

            $("#Find").click(function () {

                var valuedate = encodeURIComponent($("#<%=ddlValueDate.ClientID %> option:selected").val());
                var trn = encodeURIComponent($("#<%=ddlTrn.ClientID %> option:selected").val());
                var batchref = encodeURIComponent($("#<%=ddlBatchRef.ClientID %> option:selected").val());
                var status = encodeURIComponent($("#<%=ddlStatus.ClientID %> option:selected").val());
                var refno = encodeURIComponent($("#<%=ddlRefNo.ClientID %> option:selected").val())
                var tomember = encodeURIComponent($("#<%=ddlToMember.ClientID %> option:selected").val())
                var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_record_detail_o.ashx") %>';
                $('#table').jqGrid('setGridParam', {
                    url: handlerUrl + '?method=getdata'
                    + '&valuedate=' + valuedate
                    + '&trn=' + trn
                    + '&batchref=' + batchref
                    + '&status=' + status
                    + '&refno=' + refno
                    + '&tomember=' + tomember
                }).trigger('reloadGrid', [{ page: 1}]);
                return false;
            });
        });
    
    </script>
</asp:Content>

